package com.xgst.land.viewmodel

import com.hjq.http.EasyHttp
import com.hjq.http.listener.OnHttpListener
import com.xgst.land.base.BaseViewModel
import com.xgst.land.bean.CheckRecordBean
import com.xgst.land.bean.InventoryRecordBean
import com.xgst.land.http.api.CheckRecordAPI
import java.lang.Exception

class InventoryRecordViewModel : BaseViewModel() {
    fun request(currentPage:String, startTime:String, endTime:String, formName:String?, sampleName:String?,
                onSuccess:(MutableList<InventoryRecordBean.DataBean.PageListBean>)->Unit){
        EasyHttp.post(this)
            .api(CheckRecordAPI(
                currentPage = currentPage,
                endTime = endTime,
                startTime = startTime,
                inventoryTableName = formName?:"",
                sampleName = sampleName?:"",
                pageSize = "20"))
            .request(object : OnHttpListener<InventoryRecordBean>{
                override fun onSucceed(result: InventoryRecordBean) {
                    onSuccess(result.data.pageList)
                }

                override fun onFail(e: Exception) {
                    dismissProgress(e.message?:"")
                }
            })
    }
}
